import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:vdrag_saas/config.dart';
import 'package:vdrag_saas/detail/detail.dart';
import 'package:vdrag_saas/list/pages/home/home_tab.dart';

class ProductDetail extends StatefulWidget {
  String? id;
  ProductDetail(this.id, {super.key});

  @override
  State<ProductDetail> createState() => _ProductDetail();
}

class _ProductDetail extends State<ProductDetail> {
  @override
  Widget build(BuildContext context) {
    if (widget.id == null) {
      launchUrl(Uri.parse(HttpConfig.home), webOnlyWindowName: '_self');
      return const Text('产品不存在');
    }
    int? id = int.tryParse(widget.id!);
    if (id == null) {
      launchUrl(Uri.parse(HttpConfig.home), webOnlyWindowName: '_self');
      return const Text('产品不存在');
    }
    return Detail(onBack: null, id: id);
  }
}
